package edu.stanford.prpl.api;

import java.io.InputStream;
import java.io.OutputStream;

import edu.stanford.prpl.api.PRPLCommonMethods.IndexMethod;

public interface IndexManager extends IndexMethod {

	BlobIndexManager getBlobIndexManager();

	GroupIndexManager getGroupIndexManager();

	IdentityIndexManager getIdentityIndexManager();

	SemanticIndexManager getSemanticIndexManager();

	<T> T getBlobIndex();

	<T> T getGroupIndex();

	<T> T getIdentityIndex();

	<T> T getSemanticIndex();

	public interface BlobIndexManager {
		boolean exportBlobIndex(OutputStream outputStream);

		long getBlobIndexLastModifiedDate();

		boolean importBlobIndexFrom(String deviceURI, InputStream inputStream);

		void persistBlobIndex();

		void close();
	}

	public interface GroupIndexManager {
		boolean exportGroupIndex(OutputStream outputStream);

		long getGroupIndexLastModifiedDate();

		boolean importGroupIndex(InputStream inputStream);

		void persistGroupIndex();

		void close();
	}

	public interface IdentityIndexManager {
		boolean exportIdentityIndex(OutputStream outputStream);

		long getIdentityIndexLastModifiedDate();

		boolean importIdentityIndex(InputStream inputStream);

		void persistIdentityIndex();

		void close();
	}

	public interface SemanticIndexManager {
		boolean exportSemanticIndex(OutputStream outputStream);

		boolean exportSemanticIndexFor(String identityURI, OutputStream outputStream);

		boolean exportSemanticIndexFor(String identityURI, long updatedSince, OutputStream outputStream);

		long getSemanticIndexLastModifiedDate();

		boolean importSemanticIndexFrom(String identityURI, InputStream inputStream, boolean cleanImport);

		boolean importSemanticIndex(InputStream inputStream, boolean cleanImport);

		// boolean insertToSemanticIndexOf(String identityURI, InputStream inputStream);

		boolean removeFromSemanticIndexOf(String identityURI, InputStream inputStream);

		boolean updateSemanticIndexOf(String identityURI, InputStream oldIndex, InputStream newIndex);

		void persistSemanticIndex();

		void close();
	}

	boolean pullIndexFrom(String identityURI, long updatedSince);

	boolean pushIndexTo(String identityURI, long updatedSince);

	void close();
}

